const express = require('express');
const { graphql, buildSchema } = require('graphql');
const { graphqlHTTP } = require('express-graphql');
const app = express()
//构建schema
const schema = buildSchema(`
 type Query{
     foo:String,
     head:String

 }
`)
//resolver
const rootvalue = {
    foo() {
        return 'foo'
    }
}
//中间件
app.use('/graphql', graphqlHTTP({
    schema,
    rootValue:{foo(){return 'foo'},head(){return 22222}},
    graphiql: true
}))
app.listen(3000, () => {
    console.log('app is running')
})
